comm.set.seed(seed = rep(12345, 6), diff = FALSE,
comm = .SPMD.CT$comm)
comm.end.seed(comm = .SPMD.CT$comm)
comm.reset.seed(comm = .SPMD.CT$comm)
.GlobalEnv
, see
``rlecuyer'' package for details.comm.set.seed
set the given seed
to all ranks.
If diff = FALSE
, then all ranks generate one stream and use that
stream. Otherwise, all ranks generate COMM.SIZE
streams and
use the stream according to COMM.RANK + 1
.Sevcikova, H. and Rossini, T. (2012) rlecuyer: R interface to RNG with multiple streams. R Package, URL http://cran.r-project.org/package=rlecuyer
Programming with Big Data in R Website:
# Save code in a file "demo.r" and run with 2 processors by
# > mpiexec -np 2 Rscript demo.r
### Initial
library(pbdMPI, quiet = TRUE)
init()
### Examples
comm.set.seed()
comm.print(rnorm(5), all.rank = TRUE)
comm.reset.seed()
comm.print(rnorm(5), all.rank = TRUE)
comm.end.seed()
comm.set.seed(diff = TRUE)
comm.print(rnorm(5), all.rank = TRUE)
comm.end.seed()
### Finish
finalize()
Run the code above in your browser using DataLab